<%--
 *  File:    ProdConfSummary.jsp
 *  @Author: TendyHu
 *  Date:    2010/09/16
 *
 *  Copyright (C) 2000 - 2010 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.log4j.Category"%>
<%@ page import="com.oval.util.OvalLabel"%>
<%@ page import="com.oval.util.OvalCustomMessage"%>
<%@ page import="com.oval.util.OvalCustomColumn"%>

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval"%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>

<%
  	Category cat = Category.getInstance("jsp.ProdConfSummary"); 
  //init param
  String strModuleName = "PCM";
  String privilegeCode = "10203,L203";
  String contextPath = request.getContextPath();
  String strTableName = "ovproduct";
%>
<%
  if(request.getParameter("categoryid") != null)
  {
    session.setAttribute("categoryidsession",new Integer(request.getParameter("categoryid")));
  }
  if(request.getParameter("orgid") != null)
  {
    session.setAttribute("orgidsession",new Integer(request.getParameter("orgid")));
  }
  if(request.getParameter("categoryorgid") != null && request.getParameter("categoryorgid") != "")
  {
    session.setAttribute("categoryorgidsession",new Integer(request.getParameter("categoryorgid")));
  }
  if(request.getParameter("selectopt") != null)
  {
    session.setAttribute("selectoptsession",request.getParameter("selectopt"));
  }
  if(request.getParameter("ownerid") != null)
  {
    session.setAttribute("owneridsession",new Integer(request.getParameter("ownerid")));
  }

  Integer nCategoryId = (Integer)session.getAttribute("categoryidsession");
  Integer nOrgId = (Integer)session.getAttribute("orgidsession");
  Integer nCategoryOrgId = (Integer)session.getAttribute("categoryorgidsession");
  String strOpt = (String)session.getAttribute("selectoptsession");
  Integer nOwnerId=new Integer(-1);
  if(session.getAttribute("owneridsession")!=null)
  {
       nOwnerId = (Integer)session.getAttribute("owneridsession");
  }
%>
<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc"%>
<%@ include file="/inc/FrmDefault.inc"%>
<%@ include file="/inc/PageDefault.inc"%>
<%@ include file="/inc/LocationDefault.inc"%>

<html>
<head>
<title>ProdConfSummary</title>
<PageFlow:CheckPageFlow pageName="p_prodconfsummary" />
<link rel="stylesheet"
	href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css"
	type="text/css">
<script language="JavaScript"
	src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript"
	src="<%=contextPath %>/js/opal2/mootools.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/opal2/opal2.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/opal2/DBGrid.js"></script>
<%@ include file="/phap/inc/ExportURL.inc"%>
<%@ include file="/inc/SummaryDivision.inc"%>
<%
	HashMap pageconfiginfo = new HashMap();
    if(null!=pageContext.getAttribute("pageconfiginfo")){
	 pageconfiginfo = (HashMap)pageContext.getAttribute("pageconfiginfo");
    }
	String type = "";
	int selectmode = 3;
	if(null!=pageconfiginfo.get("selectmode")){
		selectmode=((Integer)pageconfiginfo.get("selectmode")).intValue();		
	}
	switch(selectmode){
		case 1: type = "checkbox"; break;
		case 2: type = "radio";break;
		case 3: break;
	}
	String dataIdColumn = (String)pageconfiginfo.get("dataIdColumn");
%>
<script>
function clickRow(id)
{
  document.prodconfform.id.value = id;
}

function page_delete()
{
  if(null!=document.prodconfform.prodid){
	  var id = document.prodconfform.prodid.value;
	  if(id == null || id.length == 0 || id == "" || id == "-1")
	    return;
	  var flag = confirm('<%=message.getMessageDesc("ARE_YOU_SURE_DEL")%>');
	  if(!flag)
	    return;
	  document.prodconfform.actionname.value = "delete";
	  document.prodconfform.target = "_self";
	  isRunning = true;
	  document.prodconfform.submit();
  }else{
  	alert('<%=message.getMessageDesc("PLEASE_SELECT")%>');
  }
}
function page_edit()
{
  if(null!=document.prodconfform.prodid){
	  var id = document.prodconfform.prodid.value;
	  if(id == null || id.length == 0 || id == "" || id == "-1")
	  {
	    return;
	  }
	  var nNum=Number(<%=JspHelper.filterNull((nCurPageNo.intValue()-1)*(nCurMaxItem.intValue()))%>)+Number(document.prodconfform.indexnum.value);
	  if(nNum>0) nNum=nNum-1;
	  document.prodconfform.theendindex.value=nNum;
	  document.prodconfform.actionname.value = "edit";
	  document.prodconfform.target = "_parent";
	  isRunning = true;
	  document.prodconfform.submit();  
  }else{
  	alert('<%=message.getMessageDesc("PLEASE_SELECT")%>');
  }
}
function page_new()
{
  var temporgid=<%=JspHelper.filterNull(nOrgId)%>;
  var tempownerid=<%=JspHelper.filterNull(nOwnerId)%>;
  if( temporgid==-2)
  {
     alert("<%= message.getMessageDesc("CAN_NOT_CREATE_PROD_FOR_NO_BOOKSET") %>");
     return;
  }
  var link = "ProdEditFrm.jsp?<%= OvalTools.randomURL() %>&isnew=Y&languagecode=" + "<%= strLanguageCode %>";
  link+="&orderbycolumn=<%=JspHelper.filterNull(strCurOrderByCol)%>&orderbytype=<%=JspHelper.filterNull(strCurOrderByType)%>&theendindex=0&selectopt=<oval:write property="selectoptsession"/>&categoryid=<oval:write property="categoryidsession"/>&categoryorgid=<oval:write property="categoryorgidsession"/>&orgid=<oval:write property="orgidsession"/>&searchname=<oval:write property="searchname"/>&searchvalue=<oval:write property="searchvalue"/>";
  if(tempownerid!=-1){
 	 link+="&ownerid=<%=JspHelper.filterNull(nOwnerId)%>";
  }
  parent.location.href = link;
}

function page_info(prodid)
{
  var nNum=Number(<%=JspHelper.filterNull((nCurPageNo.intValue()-1)*(nCurMaxItem.intValue()))%>)+Number(document.prodconfform.indexnum.value);
  if(nNum>0) nNum=nNum-1;
  var link = "ProdInfoFrm.jsp?<%= OvalTools.randomURL() %>&prodid=" + prodid;
  link+="&orderbycolumn=<%=JspHelper.filterNull(strCurOrderByCol)%>&orderbytype=<%=JspHelper.filterNull(strCurOrderByType)%>&theendindex="+nNum+"&selectopt=<oval:write property="selectoptsession"/>&categoryid=<oval:write property="categoryidsession"/>&categoryorgid=<oval:write property="categoryorgidsession"/>&orgid=<oval:write property="orgidsession"/>&searchname=<oval:write property="searchname"/>&searchvalue="+"<oval:write property="searchvalue"/>".replace("%","%25");

  parent.location.href = link;
}


function indicatorClick(item){
	document.prodconfform.prodid.value=item.value;
}

var dbGrid = null;
function page_summary(actionvalue,orderbyname){
	var editform = summaryPrepare(document.prodconfform,actionvalue,orderbyname);
	var myHTMLRequest = new Request({
	url:'<%=contextPath%>/Dispatcher',
	onComplete: function(responseText,responseXML) {
		var data = JSON.decode(responseText);  //获取后台生成的对象	
		dbGrid.reload(data);
		dbGrid.setDefaultSelected(0);		
		var isfirst = data.isfirst;
		dbGrid.setHiddenItemValue('isfirst', isfirst);
	}
						
	}).send($('prodconfform').toQueryString());    
}
document.addEvent('domready', function (){
	
	dbGrid = new opal.widget.DBGrid({
				'id': 'prodgrid', 
				'data': null,
				'summaryDataName': 'prods',
				'descColumnsName': 'columndesc',
				'indicator': {'type': '<%=type%>', 'dataIdColumn': '<%=dataIdColumn%>'}
			});
			dbGrid.display();		
			dbGrid.indicatorClick = indicatorClick;
			page_summary('search');	
});

function page_view(){
	var categoryid=document.prodconfform.categoryid.value;
	if(categoryid == null || categoryid.length == 0 || categoryid == "" || categoryid == "-1"){
		alert('<%= message.getMessageDesc("PLEASE_SELECT")%>');
	    return;
	}
	self.location.href = "ProdInfoFrm.jsp?<%= OvalTools.randomURL() %>&categoryid=" + categoryid;
}
function page_export(){
	var searchname = document.prodconfform.searchname.value;
	var searchvalue = document.prodconfform.searchvalue.vlaue;
	var languagecode = document.prodconfform.languagecode.value;
	var url = "<%=reportURL%>/servlet/ExcecuteReport/ExportProdmain.sox?__folder=/ovalreport&sessionid=<%=session.getId()%>&languagecode=" + languagecode;
	if(searchvalue != "" && searchvalue != null){
		url += "&" + searchname + "=" + searchvalue;
	}
	var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
    popwindow = window.open(url, "nwindow", strstatus);
}
</script>
</head>
<body>
<form name="prodconfform" id="prodconfform" method="post"
	action="<%=contextPath %>/Dispatcher" target="_self"><% //--------------------------------------  page location --%>
<%@ include file="/inc/PageLocation.inc"%>

<table width="100%" cellspacing="0" border="0" cellpadding="0">

	<input type="hidden" name="pagename" value="p_prodconfsummary">
	<input type="hidden" name="actionname" value="ajax">
	<input type="hidden" name="isfirst" id="isfirst" value="N" />

	<%if(nCategoryId != null){%>
	<input type="hidden" name="categoryid"
		value=<%=JspHelper.filterNull( nCategoryId )%>>
	<%}%>
	<custom:hidden property="languagecode" scope="session" />
	<input type="hidden" name="orgid"
		value=<%=JspHelper.filterNull( nOrgId )%>>
	<input type="hidden" name="categoryorgid"
		value=<%=JspHelper.filterNull( nCategoryOrgId )%>>
	<input type="hidden" name="selectopt"
		value=<%=JspHelper.filterNull( strOpt )%>>
	<%if(nOwnerId != null&&nOwnerId.intValue() !=-1){%>
	<input type="hidden" name="ownerid"
		value=<%=JspHelper.filterNull( nOwnerId )%>>
	<%}%>
	<input type="hidden" name="orgidsession"
		value=<%=JspHelper.filterNull( nOrgId )%>>
	<input type="hidden" name="categoryorgidsession"
		value=<%=JspHelper.filterNull( nCategoryOrgId )%>>
	<input type="hidden" name="selectoptsession"
		value=<%=JspHelper.filterNull( strOpt )%>>
	<input type="hidden" name="categoryidsession"
		value=<%=JspHelper.filterNull( nCategoryId )%>>
	<%if(nOwnerId != null&&nOwnerId.intValue() !=-1){%>
	<input type="hidden" name="owneridsession"
		value=<%=JspHelper.filterNull( nOwnerId )%>>
	<%}%>

	<tr>
		<td>
		<table width="100%" border="0" cellspacing="0">
			<%@ include file="/inc/SummarySearch.inc"%>
		</table>
		</td>
	</tr>
	<tr>
		<td>
		<div id="prodgrid"></div>
		<table width="100%" cellspacing="0" cellpadding="0">
			<tr>
				<td class="summary_top"></td>
			</tr>
			<tr>
				<td class="td_center"><a onclick="page_new();"><custom:button
					type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60" /></a>
				<a onclick="page_edit()"><custom:button type="1" label="L_Edit"
					imgsrc="edit.gif" border="0" style="width:60" /></a> <a
					onclick="page_delete()"><custom:button type="1" label="L_Delete"
					imgsrc="delete.gif" border="0" style="width:60" /></a> <a
					onclick="page_export()"><custom:button type="1" label="L_Execcd"
					imgsrc="finish.gif" border="0" style="width:60" /></a></td>
			</tr>
		</table>
		</td>
	</tr>
</table>
</form>
</body>
</html>
